var urls=require("../../utils/urls.js");
var url=require("../../utils/url.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    movieList: [],
    tvList: [],
    showList: [],
    more_data: "",
    navigate:"/pages/details/details",
  },
  click: function(type,typeName) {
    var that = this;
    type({
      count: 7,
      success: function (res) {
        console.log("======------->", res)
        res.data.subject_collection_items.push({});
        if (typeName =="movieList"){
          that.setData({
            movieList: res.data.subject_collection_items
          })
          return
        };
        if (typeName == "tvList") {
          that.setData({
            tvList: res.data.subject_collection_items
          })
          return
        };
        if (typeName == "showList") {
          that.setData({
            showList: res.data.subject_collection_items
          })
          return
        };
      }
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var that = this;
 
    var count = "?count=7"
    var pass = {
      one: {
        url: urls.movie_url,
        name: "电影"
      },
      two: {
        url: urls.tv_url,
        name: "电视剧"
      },
      three: {
        url: urls.show_url,
        name: "综艺"
      },
    }
    var more_list = {
      one: "/pages/more/more?url=" + JSON.stringify(pass.one),
      two: "/pages/more/more?url=" + JSON.stringify(pass.two),
      three: "/pages/more/more?url=" + JSON.stringify(pass.three)
    }
    this.setData({
      more_data: more_list
    })
    this.click(url.movie_data,"movieList");
    this.click(url.tv_data,"tvList");
    this.click(url.show_data,"showList");

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})